package cn.it62.pojo;

/**
 * @author zhenhuaShen
 * @version 1.0
 * @date 2019/7/30
 * @description cn.it62.pojo
 */
public class Pet {

    private String nickName;
   private String gender;
    private int age;
    private int love;
    private int health;

    public Pet() {
        System.out.println("父类Pet的无参构造方法！");
    }

    public Pet(String nickName, String gender, int age,int love){
    System.out.println("父类Pet的有参构造方法！");
            this.nickName = nickName;
            setGender(gender);
            setAge(age);
            setLove(love);
            setHealth(health);
            }

            /**
             * 默认修饰符成员，在同包和同类中可见
             */
            void setNum() {
            System.out.println("这是pet类的默认成员！");
            }

public String getNickName() {
        return nickName;
        }

public void setNickName(String nickName) {
        this.nickName = nickName;
        }

public String getGender() {
        return gender;
        }

public void setGender(String gender) {
        if ("公".equals(gender) || "母".equals(gender)) {
        this.gender = gender;
        } else {
        System.out.println("不存在的性别:" + gender);
        this.gender = "公";
        }
        }

public int getAge() {
        return age;
        }

public void setAge(int age) {
        if (age > 30 || age < 1) {
        System.out.println("年龄只能在1-30岁之间!");
        age = 2;
        }
        this.age = age;
        }

public int getLove() {
        return love;
        }

public void setLove(int love) {
        if (love > 100 || love < 1) {
        System.out.println("亲密度在1-100之间！");
        love = 50;
        }
        this.love = love;
        }

public int getHealth() {
        return health;
        }

public void setHealth(int health) {
        if (health > 100 || health < 1) {
        System.out.println("健康值在1-100之间！");
        health = 50;
        }
        this.health = health;
        }


/**
 * 吃食物
 *
 * @param food
 */
public void eat(String food) {
        System.out.println("父类pet的方法eat！");
        }

/**
 * 玩耍
 */
public void play() {
        System.out.println("父类pet的方法play！");
        }

}
